package webmagic;

import lombok.extern.slf4j.Slf4j;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

import java.util.List;

/**
 * Created by weishaofei on 2018/11/25.
 */
@Slf4j
public class MyPawler implements PageProcessor {

    private Site site = Site.me().setRetryTimes(3).setSleepTime(1000).setTimeOut(10000);


    public void process(Page page) {
        List<String> all = page.getHtml().css("div.post-thumb").all();
        log.info("all result {}", all);
    }

    public Site getSite() {
        return site;
    }

    public static void main(String[] args) {
        Spider.create(new MyPawler()).addUrl("http://www.importnew.com/").thread(5).run();
    }
}
